package com.zhiwen.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: wuzhiwen
 * @Date: 2019/2/12 13:48
 * @Description:
 */
@RestController
public class ConsumerController {
    @Autowired
    private JmsTemplate jmsTemplate;

    @RequestMapping("consumer")
    public String consumerTest() {
        return jmsTemplate.receiveAndConvert().toString();
    }

    @JmsListener(destination = "custom-destination", containerFactory = "jmsListenerContainerQueue")
    public void consumerMes(String msg) {
        System.out.println(msg);
    }

    @JmsListener(destination = "custom-destination1", containerFactory = "jmsListenerContainerTopic")
    public void consumerMes1(String msg) {
        System.out.println(msg);
    }
}
